package com.google.project.server.entity;

import java.io.Serializable;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.project.shared.SubConstructorDTO;

@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class SubConstructor implements Serializable{
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String constructorId;
	
	@Persistent
	private String constructorName;
	@Persistent
	private String description;
	@Persistent
	private String phone;
	@Persistent
	private String consultantName;
	@Persistent
	private Project project;
	
	public SubConstructor() {
	}

	
	public Project getProject() {
		return project;
	}


	public void setProject(Project project) {
		this.project = project;
	}


	public String getConstructorId() {
		return constructorId;
	}

	public void setConstructorId(String constructorId) {
		this.constructorId = constructorId;
	}

	public String getConstructorName() {
		return constructorName;
	}

	public void setConstructorName(String constructorName) {
		this.constructorName = constructorName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getConsultantName() {
		return consultantName;
	}

	public void setConsultantName(String consultantName) {
		this.consultantName = consultantName;
	}

	public SubConstructor(SubConstructorDTO subConstructor){
		this.constructorName = subConstructor.getConstructorName();
		this.description = subConstructor.getDescription();
		this.phone = subConstructor.getPhone();
		this.consultantName = subConstructor.getConsultantName();
	}
	
	public SubConstructorDTO toDTO() {
		SubConstructorDTO data = new SubConstructorDTO();
		data.setConstructorId(constructorId);
		data.setConstructorName(constructorName);
		data.setDescription(description);
		data.setPhone(phone);
		data.setConsultantName(consultantName);
		return data;
	}
	
	
	/*
	 * Update function
	 */
	public void updateFromDTO(SubConstructorDTO subConstructor){
		this.constructorName = subConstructor.getConstructorName();
		this.description = subConstructor.getDescription();
		this.phone = subConstructor.getPhone();
		this.consultantName = subConstructor.getConsultantName();
	}
	
}
